<?php

defined('ACC') || exit('Access Denied');

class GoodsTypeModel extends Model{
	
	/* 增加商品类型 */
	public function cat_name_insert($cat_name){
		$sql = "insert into goods_type (cat_name) values ('$cat_name')";
		return $this->db->query($sql);
	}
	
	/* 获取商品类型列表 */
	public function getList($pageNow, $pageSize){
		$sql='select * from goods_type order by cat_id asc limit ' . (($pageNow-1)*$pageSize) . ',' . $pageSize;
		return $this->db->getAll($sql);
	}
	
	/* 获取商品类型总行数 */
	public function rowCount(){
		$sql = 'select count(*) from goods_type';
		return $this->db->getOne($sql);
	}
	
	/* 删除某栏目下的商品类型 */
	public function delete($cat_id){
		$sql = 'delete from goods_type where cat_id = ' . $cat_id;
		return $this->db->query($sql);
	}
	
	/* 获取某栏目下的商品类型 */
	public function getRow($cat_id){
		$sql = 'select * from goods_type where cat_id = ' . $cat_id;
		return $this->db->getRow($sql);
	}
	
	/* 修改商品类型 */
	public function update($data){
		$cat_id = $data['cat_id'];
		return $this->db->autoExecute($data, 'goods_type', 'update', "cat_id = '$cat_id'");
	}
	
}


